import common.Node;
import org.junit.Test;

import static common.Node.*;
import static com.study.util.LogUtil.info;

public class LinkedList {

    void flattenList(Node node) {
        // 190601 first
    }

    @Test
    public void test() {
        Node head = createList();
        flattenList(head);
        info(head);
        info("10 -> 5 -> 12 -> 7 -> 11 -> 4 -> 20 -> 13 -> 17 -> " +
                "6 -> 2 -> 16 -> 9 -> 8 -> 3 -> 19 -> 15");
    }
}





























































/*
void flattenList(Node node) {
    if (node == null) {
        return;
    }

    Node tail = node;
    while (tail.next != null) {
        tail = tail.next;
    }

    Node cur = node;
    while (cur != tail) {
        if (cur.child != null) {
            tail.next = cur.child;
            Node tmp = cur.child;
            while (tmp.next != null) {
                tmp = tmp.next;
            }
            tail = tmp;
        }
        cur = cur.next;
    }
}
*/